﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Threading.Tasks;

namespace EventBus
{
    public  interface IEventHandler
    {
       //bool  CanHandle(IEventData eventData);
    }


    public interface IEventHandler<TEventData> : IEventHandler where TEventData : IEventData
    {
        /// <summary>
        /// 事件处理
        /// </summary>
        /// <param name="eventData">事件源数据</param>
        void Handle(TEventData eventData);
    }


    public interface IEventHandlerAsnyc<in TEventData> : IEventHandler where TEventData : IEventData
    {
        Task HandleAsync(TEventData eventData, CancellationToken cancelToken = default(CancellationToken));
    }

    //public class EventHandlerBase<TEventData> : IEventHandler<TEventData>  where TEventData : IEventData
    //{

    //    public virtual bool CanHandle(IEventData eventData)
    //    {
    //        return eventData.GetType() == typeof(TEventData);
    //    }

    //    public virtual void Handle(TEventData eventData)
    //    {
            
    //    }
    //}
}
